package com.bz.service.impl;

import com.bz.dao.EmpDao;
import com.bz.entity.Emp;
import com.bz.service.IEmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class EmpServiceImpl implements IEmpService {
    @Autowired
    private EmpDao empDao;


    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public List<Emp> findAll() {
        return empDao.findAll();
    }

    @Override
    public void save(Emp emp) {
        empDao.save(emp);
    }

    @Override
    public void delete(String id) {
        empDao.delete(id);
    }

    @Override
    public Emp findOne(String id) {
        return empDao.findOne(id);
    }

    @Override
    public void update(Emp emp) {
        empDao.update(emp);
    }


    @Override
    public List<Emp> findByPage(Integer pageNow, Integer rows) {


        int start = (pageNow-1)*rows;
        return empDao.findByPage(start,rows);
    }

    @Override
    public Long findTotals() {
        Long xxx=empDao.findTotals();
        System.out.println("----------------------");
        System.out.println("----------------------");
        System.out.println("----------------------");
        System.out.println("----------------------");
        System.out.println("----------------------");
        System.out.println("findTotals:这里"+xxx);
        return xxx;
    }

}
